package com.ymtms.arrivalofgoods.controller;

import com.ymtms.arrivalofgoods.service.NotifyCustomerService;
import com.ymtms.arrivalofgoods.service.impl.ArriveNotifyServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@CrossOrigin
public class NotifyCustomerController {
    @Autowired
    private NotifyCustomerService notifyCustomerService;

    @Autowired
    private ArriveNotifyServiceImpl arriveNotifyService;

    /**
    *Discription Todo通知客户取货
    *@Param
    *@return
    *@author Administrator
    *@date 2019/10/26 16:29
    **/
    @ResponseBody
    @RequestMapping("/notifyCustomer/{num}")
    public Map notifyCustomer(@PathVariable("num") Integer num) {

        Map notify = new HashMap();

        try {
            notifyCustomerService.notifyCustomer(num);
            //System.out.println("执行短信通知业务");
            notify.put("code", "0");
            notify.put("msg", "success");
            return notify;
        } catch (RuntimeException e) {
            e.printStackTrace();
            notify.put("code", "500");
            notify.put("msg", e.getMessage());
            return notify;
        }
    }



    /**
     *Discription Todo通知发货客户货物已被提
     *@Param
     *@return
     *@author Administrator
     *@date 2019/10/26 16:29
     **/
    @ResponseBody
    @RequestMapping("/arriveNotify/{num}")
    public Map arriveNotify(@PathVariable("num") Integer num) {

        Map notify = new HashMap();

        try {
          arriveNotifyService.notifyCustomer(num);
            //System.out.println("执行短信通知业务");
            notify.put("code", "0");
            notify.put("msg", "success");
            return notify;
        } catch (RuntimeException e) {
            e.printStackTrace();
            notify.put("code", "500");
            notify.put("msg", e.getMessage());
            return notify;
        }
    }


}
